GrapeCity.Win.Calendar 名前空間 > GcCalendar クラス > LoadHolidayFromiCalendar メソッド : LoadHolidayFromiCalendar(String,String[],Boolean) メソッド |
Public Overloads Function LoadHolidayFromiCalendar( _ ByVal fileName As String, _ ByVal categories() As String, _ ByVal onlyWholeDayEvents As Boolean _ ) As HolidayStyle
public HolidayStyle LoadHolidayFromiCalendar( string fileName, string[] categories, bool onlyWholeDayEvents )
例外 | 解説 |
---|---|
System.ArgumentException | RFC 2425の規約に準ずたiCalendarファイルではありません。 |
次の例は、このメソッドを使用してiCalendarファイルから休日を読み込む方法を示します。サンプルコードを実行するには、GcCalendarインスタンス"gcCalendar1"とSystem.Windows.Forms.Buttonインスタンス"button1"のあるSystem.Windows.Forms.Formに貼り付けます。サンプルで定義したイベントハンドラがbutton1のSystem.Windows.Forms.Control.Clickイベントに関連付けられていることを確認します。また、ディスクDにあらかじめ 'Holiday.ics'という名前のiCalendarファルを用意する必要があります。
private void button1_Click(object sender, EventArgs e) { // Specify the path of an existing iCalendar file. string path = @"D:\Holiday.ics"; // Load all the events of the iCalendar file to holidays of gcCalendar1, and get the // HolidayStyle after loading. HolidayStyle holidayStyle = this.gcCalendar1.LoadHolidayFromiCalendar(path, categories, false); if (holidayStyle == null) { MessageBox.Show("No holidays are loaded!"); return; } System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder(); foreach (IHoliday holiday in holidayStyle.Holidays) { messageBoxCS.AppendFormat("Name = {0}", holiday.Name); messageBoxCS.AppendLine(); } // Output the loaded holidays' names. MessageBox.Show(messageBoxCS.ToString(), "All holidays"); }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) ' Specify the path of an existing iCalendar file. Dim path As String = "D:\Holiday.ics" ' Load all the events of the iCalendar file to holidays of gcCalendar1, and get the ' HolidayStyle after loading. Dim holidayStyle As HolidayStyle = Me.gcCalendar1.LoadHolidayFromiCalendar(path, categories, false) If holidayStyle Is Nothing Then MessageBox.Show("No holidays are loaded!") Return End If Dim messageBoxVB As New System.Text.StringBuilder() For Each holiday As IHoliday In holidayStyle.Holidays messageBoxVB.AppendFormat("Name = {0}", holiday.Name) messageBoxVB.AppendLine() Next ' Output the loaded holidays' names. MessageBox.Show(messageBoxVB.ToString(), "All holidays") End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2